<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/taglib.jsp" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

    <title>聚人消费网络有限公司</title>
    <!--[if IE 8]>
    <script type='text/javascript' src='${ctx}/js/excanvas.js'></script>
    <link rel="stylesheet" href="${ctx}/css/IEfix.css" type="text/css" media="screen"/>
    <![endif]-->

    <!--[if IE 7]>
    <script type='text/javascript' src='${ctx}/js/excanvas.js'></script>
    <link rel="stylesheet" href="${ctx}/css/IEfix.css" type="text/css" media="screen"/>
    <![endif]-->
    <link type="text/css" href="${ctx}/css/style.css" rel="stylesheet"/>
    <!-- the layout css file -->
    <link type="text/css" href="${ctx}/css/jquery.cleditor.css" rel="stylesheet"/>

    <script type='text/javascript' src='${ctx}/js/jquery-1.4.2.min.js'></script>
    <!-- jquery library -->
    <script type='text/javascript' src='${ctx}/js/jquery-ui-1.8.5.custom.min.js'></script>
    <!-- jquery UI -->
    <script type='text/javascript' src='${ctx}/js/cufon-yui.js'></script>
    <!-- Cufon font replacement -->
    <script type='text/javascript' src='${ctx}/js/colaboratelight_400.font.js'></script>
    <!-- the Colaborate Light font -->
    <script type='text/javascript' src='${ctx}/js/easytooltip.js'></script>
    <!-- element tooltips -->
    <script type='text/javascript' src='${ctx}/js/jquery.tablesorter.min.js'></script>
    <!-- tablesorter -->


    <script type='text/javascript' src='${ctx}/js/visualize.jquery.js'></script>
    <!-- visualize plugin for graphs / statistics -->
    <script type='text/javascript' src='${ctx}/js/iphone-style-checkboxes.js'></script>
    <!-- iphone like checkboxes -->
    <script type='text/javascript' src='${ctx}/js/jquery.cleditor.min.js'></script>
    <!-- wysiwyg editor -->

    <script type='text/javascript' src='${ctx}/js/custom.js'></script>
    <!-- the "make them work" script -->


    <script type="text/javascript">
        function showDialog() {
            jQuery('#dialog').dialog({
                autoOpen:false,
                width:650,
                buttons:{
                    "提交":function () {
                        var validate = true;

                        var oldPassword = jQuery("#oldPassword").val();
                        var password = jQuery("#newPassword").val();
                        var confirmPassword = jQuery("#confirmPassword").val();

                        if (oldPassword == "") {
                            validate = false;
                            jQuery("#oldPasswordTip").attr("class", "validate_error");

                        } else {
                            jQuery("#oldPasswordTip").attr("class", "field_desc");
                        }

                        if (password == "") {
                            validate = false;
                            jQuery("#passwordTip").attr("class", "validate_error");

                        } else {
                            jQuery("#passwordTip").attr("class", "field_desc");
                        }

                        if (confirmPassword == "") {
                            validate = false;
                            jQuery("#confirmPasswordTip").attr("class", "validate_error");
                        } else {
                            jQuery("#confirmPasswordTip").attr("class", "field_desc");
                        }

                        if (confirmPassword != password) {
                            validate = false;
                            jQuery("#confirmPasswordTip").attr("class", "validate_error");
                            jQuery("#confirmPasswordTip").html("两次密码不一致");
                        } else {
                            jQuery("#confirmPasswordTip").html("请输入新密码");
                        }
                        if (validate) {
                            document.getElementById("frm").submit();
                            jQuery(this).dialog("close");
                        }
                    },
                    "取消":function () {
                        jQuery(this).dialog("close");
                    }
                }
            });
            jQuery('#dialog').dialog('open');
        }
    </script>
    <meta charset="UTF-8">
</head>

<body>

<div id="container">
    <div id="bgwrap">

        <div id="primary_left">

            <div id="logo">
                <a href="#" title="Dashboard"><img src="${ctx}/assets/LogoMaker.png" width="220" height="48"
                                                   alt=""/></a>
            </div>
            <!-- logo end -->

            <div id="menu"> <!-- navigation menu -->
                <ul>
                    <li><a href="${ctx}/forward/index/html" class="dashboard"><img
                            src="${ctx}/assets/icons/small_icons_3/dashboard.png" alt=""/><span
                            class="current">首页</span></a></li>
                    <li class="current"><a href="${ctx}/user/userManager" class="dashboard"><img
                            src="${ctx}/assets/icons/small_icons_3/users.png" alt=""/><span
                            class="current">用户管理</span></a></li>
                    <li><a href="${ctx}/album" class="dashboard"><img
                            src="${ctx}/assets/icons/small_icons_3/media.png" alt=""/><span
                            class="current">产品图片管理</span></a></li>
                    <li class="fade_hover tooltip" title="返回网站主页">
                        <a href="${ctx}">
                            <img src="${ctx}/assets/icons/dashboard/back.png" alt=""/>
                            <span>返回网站主页</span>
                        </a>
                    </li>
                </ul>
            </div>
            <!-- navigation menu end -->
        </div>
        <!-- sidebar end -->
        <div id="primary_right">
            <div class="inner" style="width: 78%;">


                <ul class="dash">


                    <li class="fade_hover tooltip" title="添加用户">
                        <a href="${ctx}/user/userAdd">
                            <img src="${ctx}/assets/icons/dashboard/add_user.png" alt=""/>
                            <span>添加用户</span>
                        </a>
                    </li>

                    <li class="fade_hover tooltip" title="修改密码">
                        <a href="javascript:showDialog();">
                            <img src="http://png-3.findicons.com/files/icons/753/gnome_desktop/64/gnome_dialog_password.png"
                                 alt=""/>
                            <span>修改密码</span>
                        </a>
                    </li>


                    <li class="fade_hover tooltip " title="退出系统">
                        <a href="${ctx}/user/logout">
                            <img src="${ctx}/assets/icons/dashboard/118.png" alt=""/>
                            <span>注销</span>
                        </a>
                    </li>

                </ul>
                <!-- end dashboard items -->

                <div id="dialog" title="修改密码" style="display: none;">
                    <form action="${ctx}/user/modifyPassword" method="post" id="frm">
                        <input name="token" type="hidden" value="${token}">
                        <fieldset>
                            <p>
                                <label>旧密码：</label>
                                <input class="sf" name="oldPassword" type="password" id="oldPassword"
                                       value=""/>
                                <span class="field_desc" id="oldPasswordTip">请输入旧密码</span>
                            </p>

                            <p>
                                <label>新密码：</label>
                                <input class="sf" name="newPassword" type="password" id="newPassword"
                                       value=""/>
                                <span class="field_desc" id="passwordTip">请输入新密码</span>
                            </p>

                            <p>
                                <label>确认新密码：</label>
                                <input class="sf"  type="password" id="confirmPassword"
                                       value=""/>
                                <span class="field_desc" id="confirmPasswordTip">请输入新密码</span>
                            </p>
                        </fieldset>
                    </form>
                </div>

                <div class="clearboth"></div>
                <c:if test="${success!=null}">
                    <div class="notification success">
                        <span></span>

                        <div class="text">
                            <p><strong>成功!</strong> ${success}</p>
                        </div>
                    </div>
                </c:if>
                <c:if test="${error!=null}">
                    <div class="notification error">
                        <span></span>

                        <div class="text">
                            <p><strong>错误!</strong> ${error}</p>
                        </div>
                    </div>
                </c:if>
                <hr/>
                <span style="font-size: 28px;font-weight: bold;">用户管理</span>
                <table class="normal tablesorter fullwidth" style="margin-top: 15px;">
                    <thead>
                    <tr>

                        <th>编号</th>
                        <th>头像</th>
                        <th>用户名</th>
                        <th>姓名</th>
                        <th>身份证</th>
                        <th>联系方式</th>
                        <th>地址</th>
                        <th>职业</th>
                        <th>性别</th>
                        <th>生日</th>
                        <th>加入日期</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${users}" var="user" varStatus="s">
                        <tr class="odd">
                            <td>${user.id}&nbsp;
                                <c:forEach var="relationUser" items="${user.relationUser}" begin="0" end="1">
                                    <c:out value="(${relationUser.id})"/>
                                </c:forEach>
                                    <%--<%=user.getRelationUser().size() != 0 ? "(" + user.getRelationUser().get(0).getId() + ")" : ""%>--%>
                            </td>
                            <td><img src="${ctx}/assets/avatar.png" alt=""/></td>
                            <td>${user.userName}
                            </td>
                            <td> ${user.nickName}
                            </td>
                            <td> ${user.idCard}
                            </td>
                            <td>${user.phone}
                            </td>
                            <td>${user.address}
                            </td>
                            <td>${user.job}
                            </td>
                            <td>${user.sex}
                            </td>
                            <td>${user.birthday}
                            </td>
                            <td>${user.joinDate}
                            </td>
                            <td>
                                <a href="${ctx}/user/userModify/${user.id}" title="编辑用户"
                                   class="tooltip table_icon"><img src="${ctx}/assets/icons/actions_small/pencil.png"
                                                                   alt=""/></a>
                                <a href="${ctx}/user/stat/${user.id}" title="查看下线用户"
                                   class="tooltip table_icon"><img
                                        src="${ctx}/assets/icons/actions_small/preferences.png"
                                        alt=""/></a>
                                <a href="${ctx}/user/userDelete/${user.id}/${token}" title="删除用户"
                                   class="tooltip table_icon"><img src="${ctx}/assets/icons/actions_small/trash.png"
                                                                   alt=""/></a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>


            </div>
            <!-- inner -->
        </div>
        <!-- primary_right -->
    </div>
    <!-- bgwrap -->
</div>
<!-- container -->
</body>
</html>